import React from "react";
import {Button, Popconfirm} from "antd";
import {PlusOutlined, DeleteOutlined} from "@ant-design/icons";

interface Props {
    onDelete?: () => void
    onAdd?: () => void
    onUpdate?: () => void
    selectedRowKeys: string[]
}

const ActionPanel = ({
                         selectedRowKeys,
                         onDelete,
                         onAdd,
                         onUpdate,
                     }: Props) => {

    const isShowPanel = onDelete || onAdd;
    const disabled = selectedRowKeys.length <= 0;


    return (
        <div className="table-action-panel">
            {onAdd && (<Button type="primary" onClick={onAdd} icon={<PlusOutlined/>}>
                新增
            </Button>)}

            {onUpdate && (<Button type="primary" onClick={onUpdate} icon={<PlusOutlined/>}>
                修改
            </Button>)}

            {onDelete && (
                <Popconfirm
                    title="您确定要删除吗？"
                    onConfirm={onDelete}
                    placement="bottomLeft"
                    okType="danger"
                >
                    <Button
                        type="primary"
                        danger
                        disabled={disabled}
                        icon={<DeleteOutlined/>}
                    >
                        批量删除
                    </Button>
                </Popconfirm>
            )}


        </div>

    )
};

export default ActionPanel;
